//===============================================================================
// Microsoft patterns & practices
// Guidance Explorer Offline Client
//===============================================================================
// Copyright  Microsoft Corporation.  All rights reserved.
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY
// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT
// LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
// FITNESS FOR A PARTICULAR PURPOSE.
//===============================================================================



using System;
using System.Collections.Generic;
using System.Windows.Forms;


namespace GuidanceExplorer.Model
{
    public class NewItemMenuItemProvider : IMenuItemsProvider
    {
        #region IMenuItemsProvider Members

        public MenuItemAttribute[] GetSubMenuItems(MenuItemAttribute parent, IModelItem modelItem)
        {
            int menuPosition = 0;
            List<MenuItemAttribute> menuItems = new List<MenuItemAttribute>();
            foreach (GuidanceType guidanceType in GuidanceType.AllGuidanceTypes)
            {
                if (!guidanceType.IsDeleted && !string.IsNullOrEmpty(guidanceType.ListDisplayName))
                {
                    menuItems.Add(new MenuItemAttribute(menuPosition++, guidanceType.NewGuidanceTypeDisplayName, guidanceType.Name, Keys.None));
                }
            }

            Comparison<MenuItemAttribute> comp = delegate(MenuItemAttribute att1, MenuItemAttribute att2)
            {
                return String.Compare(att1.MenuItemName, att2.MenuItemName);
            };
            menuItems.Sort(comp);
            return menuItems.ToArray();
        }

        #endregion
    }
}

